using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class StartScene : MonoBehaviour
{

    public Slider processSlider;
    public GameObject startBtn;
    public Button reStart;
    private float time = 2f;
    private float curtime;
    private void Awake()
    {
        Application.targetFrameRate = 60;
    }
    // Start is called before the first frame update
    void Start()
    {
        
        startBtn.SetActive(false);
        startBtn.GetComponent<Button>().onClick.AddListener(LoadMenuScene);
        reStart.onClick.AddListener(() => { curtime = 0; });
        processSlider.value = 0f;
        curtime = 0;

    }

    // Update is called once per frame
    void Update()
    {
        curtime += Time.deltaTime;
        if (curtime > time)
        {
            curtime = time;
        }
        processSlider.value = curtime/time;
        if (processSlider.value >= 1)
        {
            startBtn.SetActive(true);
        }
        else
        {
            startBtn.SetActive(false);
        }
    }
    public void LoadMenuScene()
    {
        SceneManager.LoadScene("MainMenu");
    }
}
